package org.jeecg.modules.api.controller.daping;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.util.DictUtil;
import org.jeecg.modules.api.controller.daping.mapper.DaPingMapper;
import org.jeecg.modules.api.controller.daping.vo.HyDaPingVO;
import org.jeecg.modules.wlhy.customer.service.IHyCustomerService;
import org.jeecg.modules.wlhy.hydriver.service.IHyDriverService;
import org.jeecg.modules.wlhy.hyvehicle.service.IHyVehicleService;
import org.jeecg.modules.wlhy.order.entity.HyOrder;
import org.jeecg.modules.wlhy.order.service.IHyOrderService;
import org.jeecg.modules.wlhy.setting.service.IHySettingService;
import org.jeecg.modules.wlhy.shipping.service.IHyShippingNoteService;
import org.jeecg.modules.wlhy.tj.mapper.HyTjMapper;
import org.jeecg.modules.wlhy.utils.HyCfgUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.List;

/**
 * @Author scott
 * @since 2018-12-17
 */
@RestController
@RequestMapping("/api/wlhy/daping")
@Api(tags = "大屏")
@Slf4j
public class BaiDuDaPingController {


    @Autowired
    private HyTjMapper hyTjMapper;

    @Autowired
    private IHyShippingNoteService hyShippingNoteService;

    @Autowired
    private DictUtil dictUtil;
    @Autowired
    private IHySettingService hySettingService;

    @Autowired
    private DaPingMapper daPingMapper;

    @Autowired
    private IHyDriverService driverService;
    @Autowired
    private IHyVehicleService vehicleService;

    @Autowired
    private IHyCustomerService customerService;

    @Autowired
    private IHyShippingNoteService shippingNoteService;

    @Autowired
    private IHyOrderService hyOrderService;


    //总成交金额
    @PostMapping(value = "/zongchengjiaojine")
    public String zongchengjiaojine() {
        JSONObject sjres = new JSONObject();
        String zje = null;
        if (HyCfgUtil.getCfg("caiwudaping")!=null&&HyCfgUtil.isUsed("caiwudaping")) {
            zje= HyCfgUtil.getCfgItem2("caiwudaping", "zongchengjiaojine");
        }else {
            zje = daPingMapper.getzje();
        }
        sjres.put("status", 0);
        sjres.put("msg", "");
        sjres.put("data", zje);
        return sjres.toJSONString();
    }


    public static void main(String[] args) {
        List<String> resultList = new ArrayList<String>();
        Calendar cal = Calendar.getInstance();
        //近7个月
        cal.set(Calendar.MONTH, cal.get(Calendar.MONTH) + 1); //要先+1,才能把本月的算进去
        for (int i = 0; i < 7; i++) {
            cal.set(Calendar.MONTH, cal.get(Calendar.MONTH) - 1); //逐次往前推1个月
            resultList.add(String.valueOf(cal.get(Calendar.YEAR))
                    + "-" + (cal.get(Calendar.MONTH) + 1 < 10 ? "0" +
                    (cal.get(Calendar.MONTH) + 1) : (cal.get(Calendar.MONTH) + 1)));
        }
        System.out.println(resultList);
        Collections.reverse(resultList);
    }

    //总成交金额趋势图
    @PostMapping(value = "/zcjjeqst")
    public String zcjjeqst() {
        List<String> resultList = new ArrayList<String>();
        Calendar cal = Calendar.getInstance();
        //近7个月
        cal.set(Calendar.MONTH, cal.get(Calendar.MONTH) + 1); //要先+1,才能把本月的算进去
        for (int i = 0; i < 7; i++) {
            cal.set(Calendar.MONTH, cal.get(Calendar.MONTH) - 1); //逐次往前推1个月
            resultList.add(String.valueOf(cal.get(Calendar.YEAR))
                    + "-" + (cal.get(Calendar.MONTH) + 1 < 10 ? "0" +
                    (cal.get(Calendar.MONTH) + 1) : (cal.get(Calendar.MONTH) + 1)));
        }

        List<String> categories = new ArrayList<String>();
        List<String> data2 = new ArrayList<String>();
        Collections.reverse(resultList);
        Collections.reverse(resultList);
        if (HyCfgUtil.getCfg("zcjjeqst")!=null&&HyCfgUtil.isUsed("zcjjeqst")) {
            String day1 = HyCfgUtil.getCfgItem2("zcjjeqst", "day1");
            data2.add(day1);
            String day2 = HyCfgUtil.getCfgItem2("zcjjeqst", "day2");
            data2.add(day2);
            String day3 = HyCfgUtil.getCfgItem2("zcjjeqst", "day3");
            data2.add(day3);
            String day4 = HyCfgUtil.getCfgItem2("zcjjeqst", "day4");
            data2.add(day4);
            String day5 = HyCfgUtil.getCfgItem2("zcjjeqst", "day5");
            data2.add(day5);
            String day6 = HyCfgUtil.getCfgItem2("zcjjeqst", "day6");
            data2.add(day6);
            String day7 = HyCfgUtil.getCfgItem2("zcjjeqst", "day7");
            data2.add(day7);
            for (String s : resultList) {
                    categories.add(s);
            }
        }else {
            for (String s : resultList) {
                HyDaPingVO getzcjje = daPingMapper.getzcjje(s);
                if (getzcjje == null) {
                    categories.add(s);
                    data2.add("0");
                } else {
                    categories.add(s);
                    data2.add(getzcjje.getValue() == null ? "0" : getzcjje.getValue());
                }
            }
        }

        JSONArray series = new JSONArray();
        JSONObject serie = new JSONObject();
        serie.put("data", data2);
        serie.put("name", "元");

        series.add(serie);
        JSONObject data = new JSONObject();
        data.put("categories", categories);
        data.put("series", series);
        JSONObject obj = new JSONObject();
        obj.put("status", 0);
        obj.put("msg", "");
        obj.put("data", data);
        return obj.toJSONString();

    }


    //总成交订单趋势图
    @PostMapping(value = "/zcjddqst")
    public String zcjddqst() {
        List<String> resultList = new ArrayList<String>();
        Calendar cal = Calendar.getInstance();
        //近7个月
        cal.set(Calendar.MONTH, cal.get(Calendar.MONTH) + 1); //要先+1,才能把本月的算进去
        for (int i = 0; i < 7; i++) {
            cal.set(Calendar.MONTH, cal.get(Calendar.MONTH) - 1); //逐次往前推1个月
            resultList.add(String.valueOf(cal.get(Calendar.YEAR))
                    + "-" + (cal.get(Calendar.MONTH) + 1 < 10 ? "0" +
                    (cal.get(Calendar.MONTH) + 1) : (cal.get(Calendar.MONTH) + 1)));
        }

        List<String> categories = new ArrayList<String>();
        List<String> data2 = new ArrayList<String>();
        Collections.reverse(resultList);
        if (HyCfgUtil.getCfg("zcjddqst")!=null&&HyCfgUtil.isUsed("zcjddqst")) {
            String day1 = HyCfgUtil.getCfgItem2("zcjddqst", "day1");
            data2.add(day1);
            String day2 = HyCfgUtil.getCfgItem2("zcjddqst", "day2");
            data2.add(day2);
            String day3 = HyCfgUtil.getCfgItem2("zcjddqst", "day3");
            data2.add(day3);
            String day4 = HyCfgUtil.getCfgItem2("zcjddqst", "day4");
            data2.add(day4);
            String day5 = HyCfgUtil.getCfgItem2("zcjddqst", "day5");
            data2.add(day5);
            String day6 = HyCfgUtil.getCfgItem2("zcjddqst", "day6");
            data2.add(day6);
            String day7 = HyCfgUtil.getCfgItem2("zcjddqst", "day7");
            data2.add(day7);
            for (String s : resultList) {
                    categories.add(s);
            }
        }else {
            for (String s : resultList) {
                HyDaPingVO getzcjje = daPingMapper.getzcjdd(s);
                if (getzcjje != null) {
                    categories.add(s);
                    data2.add(getzcjje.getValue() == null ? "0" : getzcjje.getValue());
                }
            }
        }

        JSONArray series = new JSONArray();
        JSONObject serie = new JSONObject();
        serie.put("data", data2);
        serie.put("name", "单");

        series.add(serie);
        JSONObject data = new JSONObject();
        data.put("categories", categories);
        data.put("series", series);
        JSONObject obj = new JSONObject();
        obj.put("status", 0);
        obj.put("msg", "");
        obj.put("data", data);
        return obj.toJSONString();

    }


    //承运订单概览
    @PostMapping(value = "/cyddgl")
    public String cyddgl() {
        JSONArray data = new JSONArray();
        int wanjie = 0;
        int chexiao = 0;
        int diaodu = 0;
        int daishouli = 0;
        if (HyCfgUtil.getCfg("cyddgl")!=null&&HyCfgUtil.isUsed("cyddgl")) {
             wanjie = Integer.parseInt(HyCfgUtil.getCfgItem2("cyddgl", "wanjie"));
            chexiao = Integer.parseInt(HyCfgUtil.getCfgItem2("cyddgl", "chexiao"));
            diaodu = Integer.parseInt(HyCfgUtil.getCfgItem2("cyddgl", "diaodu"));
            daishouli = Integer.parseInt(HyCfgUtil.getCfgItem2("cyddgl", "daishouli"));
        }else {
            wanjie = hyOrderService.count(new QueryWrapper<HyOrder>().eq("order_status", "8"));
            chexiao = hyOrderService.count(new QueryWrapper<HyOrder>().eq("del_flag", "-1"));
            diaodu = hyOrderService.count(new QueryWrapper<HyOrder>().eq("order_status", "2"));
            daishouli = hyOrderService.count(new QueryWrapper<HyOrder>().eq("order_status", "0"));
        }

        JSONObject sjres = new JSONObject();

        sjres.put("name", "已完结");
        sjres.put("value", wanjie);
        data.add(sjres);
        JSONObject sjres1 = new JSONObject();
        sjres1.put("name", "已撤销");
        sjres1.put("value", chexiao);
        data.add(sjres1);
        JSONObject sjres2 = new JSONObject();
        sjres2.put("name", "调度中");
        sjres2.put("value", diaodu);
        data.add(sjres2);
        JSONObject sjres3 = new JSONObject();
        sjres3.put("name", "待受理");
        sjres3.put("value", daishouli);
        data.add(sjres3);

        JSONObject obj = new JSONObject();
        obj.put("status", 0);
        obj.put("msg", "");
        obj.put("data", data);

        return obj.toJSONString();

    }


    //近7日调度量
    @PostMapping(value = "/jqrddl")
    public String jqrddl() {

        List<String> resultList = new ArrayList<String>();
        Calendar c = null;
        //近7个日
        for (int i = 0; i < 7; i++) {
            c = Calendar.getInstance();
            c.add(Calendar.DAY_OF_MONTH, -i);
            resultList.add(c.get(Calendar.YEAR)
                    + "-" + (c.get(Calendar.MONTH) + 1 < 10 ? "0" +
                    (c.get(Calendar.MONTH) + 1) : (c.get(Calendar.MONTH) + 1)) + "-" +
                    (c.get(Calendar.DAY_OF_MONTH) < 10 ? "0" +
                            (c.get(Calendar.DAY_OF_MONTH)) : (c.get(Calendar.DAY_OF_MONTH))));
        }

        List<String> categories = new ArrayList<String>();
        List<String> data2 = new ArrayList<String>();
        Collections.reverse(resultList);
        if (HyCfgUtil.getCfg("jqrddl")!=null&&HyCfgUtil.isUsed("jqrddl")) {
            String day1 = HyCfgUtil.getCfgItem2("jqrddl", "day1");
            data2.add(day1);
            String day2 = HyCfgUtil.getCfgItem2("jqrddl", "day2");
            data2.add(day2);
            String day3 = HyCfgUtil.getCfgItem2("jqrddl", "day3");
            data2.add(day3);
            String day4 = HyCfgUtil.getCfgItem2("jqrddl", "day4");
            data2.add(day4);
            String day5 = HyCfgUtil.getCfgItem2("jqrddl", "day5");
            data2.add(day5);
            String day6 = HyCfgUtil.getCfgItem2("jqrddl", "day6");
            data2.add(day6);
            String day7 = HyCfgUtil.getCfgItem2("jqrddl", "day7");
            data2.add(day7);
            for (String s : resultList) {
                HyDaPingVO getzcjje = daPingMapper.getzcjds(s);
                if (getzcjje != null) {
                    categories.add(getzcjje.getName());
                }
            }
        }else {
            for (String s : resultList) {
                HyDaPingVO getzcjje = daPingMapper.getzcjds(s);
                if (getzcjje != null) {
                    categories.add(getzcjje.getName());
                    data2.add(getzcjje.getValue() == null ? "0" : getzcjje.getValue());
                }
            }
        }

        JSONArray series = new JSONArray();
        JSONObject serie = new JSONObject();
        serie.put("data", data2);
        serie.put("name", "吨");
        series.add(serie);
        JSONObject data = new JSONObject();
        data.put("categories", categories);
        data.put("series", series);
        JSONObject obj = new JSONObject();
        obj.put("status", 0);
        obj.put("msg", "");
        obj.put("data", data);
        return obj.toJSONString();

    }

    //近7日交易
    @PostMapping(value = "/jqrje")
    public String jqrje() {

        List<String> resultList = new ArrayList<String>();
        Calendar c = null;
        //近7个日
        for (int i = 0; i < 7; i++) {
            c = Calendar.getInstance();
            c.add(Calendar.DAY_OF_MONTH, -i);
            resultList.add(c.get(Calendar.YEAR)
                    + "-" + (c.get(Calendar.MONTH) + 1 < 10 ? "0" +
                    (c.get(Calendar.MONTH) + 1) : (c.get(Calendar.MONTH) + 1)) + "-" +
                    (c.get(Calendar.DAY_OF_MONTH) < 10 ? "0" +
                            (c.get(Calendar.DAY_OF_MONTH)) : (c.get(Calendar.DAY_OF_MONTH)))
            );
        }

        List<String> categories = new ArrayList<String>();
        List<String> data2 = new ArrayList<String>();
        Collections.reverse(resultList);
        if (HyCfgUtil.getCfg("jqrje")!=null&&HyCfgUtil.isUsed("jqrje")) {
            String day1 = HyCfgUtil.getCfgItem2("jqrje", "day1");
            data2.add(day1);
            String day2 = HyCfgUtil.getCfgItem2("jqrje", "day2");
            data2.add(day2);
            String day3 = HyCfgUtil.getCfgItem2("jqrje", "day3");
            data2.add(day3);
            String day4 = HyCfgUtil.getCfgItem2("jqrje", "day4");
            data2.add(day4);
            String day5 = HyCfgUtil.getCfgItem2("jqrje", "day5");
            data2.add(day5);
            String day6 = HyCfgUtil.getCfgItem2("jqrje", "day6");
            data2.add(day6);
            String day7 = HyCfgUtil.getCfgItem2("jqrje", "day7");
            data2.add(day7);
            for (String s : resultList) {
                HyDaPingVO getzcjje = daPingMapper.getzcje(s);
                if (getzcjje != null) {
                    categories.add(getzcjje.getName());
                }
            }
        }else {
            for (String s : resultList) {
                HyDaPingVO getzcjje = daPingMapper.getzcje(s);
                if (getzcjje != null) {
                    categories.add(getzcjje.getName());
                    data2.add(getzcjje.getValue() == null ? "0" : getzcjje.getValue());
                }
            }
        }

        JSONArray series = new JSONArray();
        JSONObject serie = new JSONObject();
        serie.put("data", data2);
        serie.put("name", "元");
        series.add(serie);
        JSONObject data = new JSONObject();
        data.put("categories", categories);
        data.put("series", series);
        JSONObject obj = new JSONObject();
        obj.put("status", 0);
        obj.put("msg", "");
        obj.put("data", data);
        return obj.toJSONString();

    }


    //交易总额
    @PostMapping(value = "/jiaoyizonge")
    public String jiaoyizonge(String type) {

        Calendar cal = Calendar.getInstance();
        List<JSONObject> list = new ArrayList<>();
        cal.add(Calendar.DATE, -1);
        String yesterday = new SimpleDateFormat("yyyy-MM-dd ").format(cal.getTime());
        HyDaPingVO getzcjje = daPingMapper.getzcjjeri(yesterday);

        JSONObject obj = new JSONObject();

        if (HyCfgUtil.getCfg("caiwudaping")!=null&&HyCfgUtil.isUsed("caiwudaping")) {
            String zuo1 = HyCfgUtil.getCfgItem2("caiwudaping", "zuo1");
            obj.put("status", 0);
            obj.put("msg", "");
            obj.put("type", "zuo1");
            obj.put("data", zuo1);
        } else if (getzcjje != null) {
            obj.put("status", 0);
            obj.put("msg", "");
            obj.put("type", "zuo1");
            obj.put("data", getzcjje.getValue() == null ? "0" : getzcjje.getValue());
        } else {
            obj.put("status", 0);
            obj.put("msg", "");
            obj.put("type", "zuo1");
            obj.put("data", "0");
        }

        list.add(obj);//昨日订单总额


        String zuo2yesterday = new SimpleDateFormat("yyyy-MM-dd ").format(cal.getTime());
        HyDaPingVO zuo2getzcjje = daPingMapper.getzcjddri(zuo2yesterday);
        JSONObject zuo2obj = new JSONObject();
        if (HyCfgUtil.getCfg("caiwudaping")!=null&&HyCfgUtil.isUsed("caiwudaping")) {
            String zuo2 = HyCfgUtil.getCfgItem2("caiwudaping", "zuo2");
            zuo2obj.put("status", 0);
            zuo2obj.put("msg", "");
            zuo2obj.put("type", "zuo2");
            zuo2obj.put("data",zuo2);
        }else {
            if (zuo2getzcjje != null) {
                zuo2obj.put("status", 0);
                zuo2obj.put("msg", "");
                zuo2obj.put("type", "zuo2");
                zuo2obj.put("data", zuo2getzcjje.getValue() == null ? "0" : zuo2getzcjje.getValue());

            } else {
                zuo2obj.put("status", 0);
                zuo2obj.put("msg", "");
                zuo2obj.put("type", "zuo2");
                zuo2obj.put("data", "0");
            }
        }

        list.add(zuo2obj);//昨日交易笔数



            String zuo3yesterday = new SimpleDateFormat("yyyy-MM-dd ").format(cal.getTime());
            HyDaPingVO zuo3getzcjje = daPingMapper.getzcjjeri(zuo3yesterday);
            HyDaPingVO zuo3getzcjdd = daPingMapper.getzcjddri(zuo3yesterday);
            JSONObject zuo3obj = new JSONObject();
            if (HyCfgUtil.getCfg("caiwudaping")!=null&&HyCfgUtil.isUsed("caiwudaping")) {
            String zuo3 = HyCfgUtil.getCfgItem2("caiwudaping", "zuo3");
            zuo3obj.put("status", 0);
            zuo3obj.put("msg", "");
            zuo3obj.put("type", "zuo3");
            zuo3obj.put("data", zuo3);
            }else if (zuo3getzcjje != null && zuo3getzcjdd != null) {
                    Double je = Double.valueOf(zuo3getzcjje.getValue() == null ? "0" : zuo3getzcjje.getValue());
                    Double dd = Double.valueOf(zuo3getzcjdd.getValue() == null ? "0" : zuo3getzcjdd.getValue());
                    Double jun = je / dd;
                    zuo3obj.put("status", 0);
                    zuo3obj.put("msg", "");
                    zuo3obj.put("type", "zuo3");
                    zuo3obj.put("data", String.format("%.2f", jun));

            } else {
                    zuo3obj.put("status", 0);
                    zuo3obj.put("msg", "");
                    zuo3obj.put("type", "zuo3");
                    zuo3obj.put("data", "0");
            }

            list.add(zuo3obj);//昨天交易总额

        cal.add(Calendar.DATE, +1);
            String jin1yesterday = new SimpleDateFormat("yyyy-MM-dd ").format(cal.getTime());
            HyDaPingVO jin1getzcjje = daPingMapper.getzcjjeri(jin1yesterday);
            JSONObject jin1obj = new JSONObject();
            if (HyCfgUtil.getCfg("caiwudaping")!=null&&HyCfgUtil.isUsed("caiwudaping")) {
                String jin1 = HyCfgUtil.getCfgItem2("caiwudaping", "jin1");
                jin1obj.put("status", 0);
                jin1obj.put("msg", "");
                jin1obj.put("type", "jin1");
                jin1obj.put("data", jin1);
            }else if (jin1getzcjje != null) {
                jin1obj.put("status", 0);
                jin1obj.put("msg", "");
                jin1obj.put("type", "jin1");
                jin1obj.put("data", jin1getzcjje.getValue() == null ? "0" : jin1getzcjje.getValue());
            } else {
                jin1obj.put("status", 0);
                jin1obj.put("msg", "");
                jin1obj.put("type", "jin1");
                jin1obj.put("data", "0");
            }
        list.add(jin1obj);//今日交易总额
            String jin2yesterday = new SimpleDateFormat("yyyy-MM-dd ").format(cal.getTime());
            HyDaPingVO jin2getzcjje = daPingMapper.getzcjddri(jin2yesterday);
            JSONObject jin2obj = new JSONObject();
            if (HyCfgUtil.getCfg("caiwudaping")!=null&&HyCfgUtil.getCfg("caiwudaping")!=null&&HyCfgUtil.isUsed("caiwudaping")) {
                String jin2 = HyCfgUtil.getCfgItem2("caiwudaping", "jin2");
                jin2obj.put("status", 0);
                jin2obj.put("msg", "");
                jin2obj.put("type", "jin2");
                jin2obj.put("data", jin2);
            }else if (getzcjje != null) {
                    jin2obj.put("status", 0);
                    jin2obj.put("msg", "");
                    jin2obj.put("type", "jin2");
                    if (HyCfgUtil.getCfg("caiwudaping")!=null&&HyCfgUtil.isUsed("caiwudaping")) {
                        String jin2 = HyCfgUtil.getCfgItem2("caiwudaping", "jin2");
                        jin2obj.put("data", jin2);
                    }else {
                        jin2obj.put("data", jin2getzcjje.getValue() == null ? "0" : jin2getzcjje.getValue());
                    }

                } else {
                    jin2obj.put("status", 0);
                    jin2obj.put("msg", "");
                    jin2obj.put("type", "jin2");
                    jin2obj.put("data", "0");
            }

        list.add(jin2obj);//今日交易笔数

            String jin3yesterday = new SimpleDateFormat("yyyy-MM-dd ").format(cal.getTime());
            HyDaPingVO jin3getzcjje = daPingMapper.getzcjjeri(jin3yesterday);
            HyDaPingVO jin3getzcjdd = daPingMapper.getzcjddri(jin3yesterday);
            JSONObject jin3obj = new JSONObject();
            if (HyCfgUtil.getCfg("caiwudaping")!=null&&HyCfgUtil.isUsed("caiwudaping")) {
                String jin3 = HyCfgUtil.getCfgItem2("caiwudaping", "jin3");
                jin3obj.put("status", 0);
                jin3obj.put("msg", "");
                jin3obj.put("type", "jin3");
                jin3obj.put("data", jin3);
            }else if (jin3getzcjje != null && jin3getzcjdd != null) {

                Double je = Double.valueOf(jin3getzcjje.getValue() == null ? "0" : jin3getzcjje.getValue());
                Double dd = Double.valueOf(jin3getzcjdd.getValue() == null ? "0" : jin3getzcjdd.getValue());
                Double jun = je / dd;
                jin3obj.put("status", 0);
                jin3obj.put("msg", "");
                jin3obj.put("type", "jin3");
                jin3obj.put("data", String.format("%.2f", jun));

            } else {
                jin3obj.put("status", 0);
                jin3obj.put("msg", "");
                jin3obj.put("type", "jin3");
                jin3obj.put("data", "0");
            }
        list.add(jin3obj);//今日订单金额

            HyDaPingVO qi1getzcjje = daPingMapper.get7je();
            JSONObject qi1obj = new JSONObject();
            if (HyCfgUtil.getCfg("caiwudaping")!=null&&HyCfgUtil.isUsed("caiwudaping")) {
                String qi1 = HyCfgUtil.getCfgItem2("caiwudaping", "qi1");
                qi1obj.put("status", 0);
                qi1obj.put("msg", "");
                qi1obj.put("type", "qi1");
                qi1obj.put("data", qi1);
            }else if (qi1getzcjje != null) {
                qi1obj.put("status", 0);
                qi1obj.put("msg", "");
                qi1obj.put("type", "qi1");
                qi1obj.put("data", qi1getzcjje.getValue() == null ? "0" : qi1getzcjje.getValue());
            } else {
                qi1obj.put("status", 0);
                qi1obj.put("msg", "");
                qi1obj.put("type", "qi1");
                qi1obj.put("data", "0");
            }
        list.add(qi1obj);//七日交易总额
            HyDaPingVO qi2getzcjje = daPingMapper.get7dd();
            JSONObject qi2obj = new JSONObject();
            if (HyCfgUtil.getCfg("caiwudaping")!=null&&HyCfgUtil.isUsed("caiwudaping")) {
                String qi2 = HyCfgUtil.getCfgItem2("caiwudaping", "qi2");
                qi2obj.put("status", 0);
                qi2obj.put("msg", "");
                qi2obj.put("type", "qi2");
                qi2obj.put("data", qi2);
            }else if (qi2getzcjje != null) {
                qi2obj.put("status", 0);
                qi2obj.put("msg", "");
                qi2obj.put("type", "qi2");

                qi2obj.put("data", qi2getzcjje.getValue() == null ? "0" : qi2getzcjje.getValue());
            } else {
                qi2obj.put("status", 0);
                qi2obj.put("msg", "");
                qi2obj.put("type", "qi2");
                qi2obj.put("data", "0");
            }
        list.add(qi2obj);//七日交易笔数

            HyDaPingVO qi3getzcjje = daPingMapper.get7je();
            HyDaPingVO qi3getzcjdd = daPingMapper.get7dd();
            JSONObject qi3obj = new JSONObject();
            if (HyCfgUtil.getCfg("caiwudaping")!=null&&HyCfgUtil.isUsed("caiwudaping")) {
                String qi3 = HyCfgUtil.getCfgItem2("caiwudaping", "qi3");
                qi3obj.put("status", 0);
                qi3obj.put("msg", "");
                qi3obj.put("type", "qi3");
                qi3obj.put("data", qi3);
            }else if (qi3getzcjje != null && qi3getzcjdd != null) {
                Double je = Double.valueOf(qi3getzcjje.getValue() == null ? "0" : qi3getzcjje.getValue());
                Double dd = Double.valueOf(qi3getzcjdd.getValue() == null ? "0" : qi3getzcjdd.getValue());
                Double jun = je / dd;
                qi3obj.put("status", 0);
                qi3obj.put("msg", "");
                qi3obj.put("type", "qi3");


                qi3obj.put("data", String.format("%.2f", jun));


            } else {
                qi3obj.put("status", 0);
                qi3obj.put("msg", "");
                qi3obj.put("type", "qi3");
                qi3obj.put("data", "0");
            }
        list.add(qi3obj);//七日订单金额

        return list.toString();

    }


}
